<template>
  <div id="SmartPush">
    <el-row>
      <el-col :span="4">
        <div class="div_border_title">
          <h2>智能推送</h2>
        </div>
      </el-col>
    </el-row>
    <el-row class="content">
      <el-col :span="10">
        <el-card class="box-card">
          <div slot="header">
            <span>简历列表</span>
          </div>
          <div style="text-align:center;">
            <el-input icon="search" v-model="resumeSearch"
                      :on-icon-click="handleIconClick" class="search">
            </el-input>
            <el-table ref="multipleTable" :data="resumeList" border
                      tooltip-effect="dark" @selection-change="handleSelectResume">
              <el-table-column type="selection" width="55">
              </el-table-column>
              <el-table-column prop="name" label="简历名称"
                               align="center">
              </el-table-column>
              <el-table-column prop="end_education" label="评分" align="center">
              </el-table-column>
            </el-table>
            <el-pagination @current-change="handleChangeResume" layout="total, prev, pager, next" :total="resumeTotal"
                           class="table-page-style"></el-pagination>
          </div>
        </el-card>
      </el-col>
      <el-col :span="4">
        <div class="buttons">
          <el-button type="primary"><i class="el-icon-arrow-left"></i>推送到用户</el-button>
          <el-button type="primary">推送到企业<i class="el-icon-arrow-right"></i></el-button>
        </div>
      </el-col>
      <el-col :span="10">
        <el-card class="box-card">
          <div slot="header">
            <span>职位列表</span>
          </div>
          <div style="text-align:center;">
            <el-input icon="search" v-model="positionSearch" :on-icon-click="handleIconClick" class="search">
            </el-input>
            <el-table ref="multipleTable" :data="positionList" border
                      tooltip-effect="dark" @selection-change="handleSelectPosition">
              <el-table-column type="selection" width="55">
              </el-table-column>
              <el-table-column prop="job_title" label="职位名称"
                               align="center">
              </el-table-column>
              <el-table-column prop="company_name" label="所属公司" align="center" show-overflow-tooltip>
              </el-table-column>
            </el-table>
            <el-pagination @current-change="handleChangePosition" layout="total, prev, pager, next"
                           :total="positionTotal" class="table-page-style"></el-pagination>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import { postDataToServer } from '../../assets/js/post.js'
  import { getStaticMapList } from '../../assets/js/GlobeDefine.js'
  import UserEntryDialog from '@/components/userLogin/UserEntryDialog'
  import { formatterTime, changeSalaryStyle } from '../../assets/js/common.js'

  export default {
    name: 'SmartPush',
    data () {
      return {
        resumeSearch: '',
        resumeTotal: 0,
        resumeList: [],
        positionSearch: '',
        positionTotal: 0,
        positionList: []
      }
    },
    created () {
      this.getResumeList(1)
      this.getPositionList(1)
    },
    methods: {
      getResumeList (page) {
        let _this = this
        let pragram = new Object()
        pragram.page_size = 10
        pragram.page_no = page
        postDataToServer('HM_RESUME_TALENTS_LIST', pragram).then((data) => {
          if (data.status === 0) {
            _this.resumeTotal = data.total_results
            _this.resumeList = data.data_list
            for (let i = 0; i < data.data_list.length; i++) {
              if (_this.resumeList[i].work_years === undefined) {
                _this.resumeList[i].work_years = 0
              }
              _this.resumeList[i].end_education = getStaticMapList('education', _this.resumeList[i].end_education)
              _this.resumeList[i].sex = getStaticMapList('sex', _this.resumeList[i].sex)
            }
          }
        })
      },
      getPositionList (page) {
        let _this = this
        let pragram = new Object()
        pragram.page_size = 10
        pragram.page_no = page
        postDataToServer('HM_RESUME_JOBS_LIST', pragram).then((data) => {
          if (data.status === 0) {
            _this.positionTotal = data.total_results
            data.data_list.forEach((item) => {
              item = changeSalaryStyle(item)
            })
            _this.positionList = data.data_list
          }
        })
      },
      handleSelectResume () {

      },
      handleSelectPosition () {

      },
      handleChangeResume (pageNum) {
        this.getResumeList(pageNum)
      },
      handleChangePosition (pageNum) {
        this.getPositionList(pageNum)
      },
      handleIconClick () {

      }
    }
  }
</script>

<style>
  #SmartPush {
    padding: 2em;
  }

  .content {
    margin-top: 2em;
  }

  .buttons {
    text-align: center;
    padding-top: 5em;
  }

  .buttons button {
    margin: 3em 0em 0em;
  }

  .search {
    width: 80%;
    margin: 0em auto 1.5em;
  }
</style>
